<template>
	<view class="infoBox ">
		<view class="infoTitle" v-if="loading">
			<view style="height: 30rpx;width: 80%;" class="Skeleton" />
		</view>
		<view class="infoTitle" v-else>
			<u-icon name='clock' size='28rpx' />
			<view class="title">
				全部动态
			</view>
			<u-icon name='arrow-down-fill' size='28rpx' :label='processesTitle' labelPos='left' @click='show=true' />
		</view>
		<view class="infoContent">
			<template v-if="loading">
				<view class="userBox">
					<view class="Skeleton" style="height: 80rpx;width: 80rpx;" />
					<view class="userInfo">
						<view class="Skeleton" style="height: 30rpx;" v-for="item in 2" :key="item" />
					</view>
				</view>
				<view v-for="(item,index) in 5" :key="index">
					<view class="Skeleton" style="height: 30rpx;margin-bottom: 20rpx;" v-for="item in 4" :key="item" />
					<view>
						<album :loading='loading' />
					</view>
				</view>
			</template>
			<template v-else>
				<view v-for="(item,index) in active" :key="index" class="mb20 activeBox">
					<view class="userBox">
						<u-avatar size='80rpx' :src='item.user.avatar' />
						<view class="userInfo">
							<view>
								{{item.user.nick_name}}
							</view>
							<view>
								{{item.created_at | changeTime}}
							</view>
						</view>
						<view class="activeProcess">
							{{item.process.title}}
						</view>
					</view>
					<view style="margin: 10rpx 0;">
						<u-parse :content="item.title"></u-parse>
					</view>
					<view>
						<album :ref='`album${index}`' :imageList='item.images'
							:video='item.videos.map(imageItem=>imageItem.url)' :index='index' :playIndex='playIndex' />
					</view>
				</view>
				<view v-if="!active.length">
					<empty />
				</view>
			</template>
		</view>
		<root-portal>
			<u-picker keyName="title" :show="show" :columns="processesList" @confirm='confirm'
				@cancel='show=false'></u-picker>
		</root-portal>
	</view>
</template>

<script>
	import album from '@/components/album.vue';
	export default {
		components: {
			album,
		},
		props: ['loading', 'prorcessesId', 'activities', 'playIndex', 'processes'],
		computed: {
			active() {
				return this.activities
			},
			processesList() {
				return [this.processes]
			},
			processesTitle() {
				if (this.prorcessesId) {
					return this.processes.filter(item => item.id == this.prorcessesId)[0].title
				}

				return '阶段筛选'
			}
		},
		data() {
			return {
				show: false
			}
		},
		mounted() {

		},
		methods: {
			confirm(e) {
				this.$emit('prorcessesChange', e.value[0].id)
				this.show = false
			}
		}
	}
</script>

<style lang="scss" scoped>
	.infoBox {
		border-radius: 8rpx;
		background-color: #fff;
		box-shadow: 0 0 10rpx #eee;
		width: 680rpx;
		margin: 20rpx auto 0;

		.infoTitle {
			display: flex;
			align-items: center;
			border-bottom: 1rpx solid #ddd;
			padding: 20rpx 40rpx;
			justify-content: space-between;

			.title {
				flex: 1;
				font-size: 28rpx;
				margin-left: 20rpx;
			}
		}

		.infoContent {
			padding: 20rpx 40rpx;
		}
	}

	.userBox {
		display: flex;
		align-items: center;
		margin-bottom: 20rpx;
		>view:nth-child(2) {
			flex: 1;
			margin: 0 20rpx;
			height: 80rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
		}

		.activeProcess {
			color: #fff;
			background-color: green;
			border-radius: 4rpx;
			padding: 4rpx 10rpx;
		}
	}

	.mb20 {
		padding: 0 0 20rpx;
		border-bottom: 1rpx solid #ddd;
		margin-bottom: 20rpx;
	}
</style>